import 'package:flutter/material.dart';

class TagsSection extends StatelessWidget {
  final List<String> tags;
  final Set<int> addedTags;
  final Function(String, int) onTagTap;

  const TagsSection({
    Key? key,
    required this.tags,
    required this.addedTags,
    required this.onTagTap,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    List<MapEntry<int, String>> availableTags = tags
        .asMap()
        .entries
        .where((entry) => !addedTags.contains(entry.key))
        .toList();

    if (availableTags.isEmpty) {
      return SizedBox.shrink();
    }

    return Wrap(
      spacing: 8,
      runSpacing: 8,
      children: availableTags.map((entry) {
        int index = entry.key;
        String tag = entry.value;

        return GestureDetector(
          onTap: () => onTagTap(tag, index),
          child: Container(
            padding: EdgeInsets.symmetric(horizontal: 12, vertical: 6),
            decoration: BoxDecoration(
              color: Colors.grey[800],
              borderRadius: BorderRadius.circular(16),
            ),
            child: Text(
              tag,
              style: TextStyle(color: Colors.white, fontSize: 14),
            ),
          ),
        );
      }).toList(),
    );
  }
}
